var ZYRequestClient = require("../../../../utils/zy-request");
var requestClient;
const app = getApp();
Page({
  data:{
    alarmRecordList:[],
    navbarData:{
      showCapsule: 1, //是否显示左上角图标   1表示显示    0表示不显示
      title: '报警记录', //导航栏 中间的标题
      white:true
     },
     // 导航头的高度
     height: app.globalData.height * 2 + 20
  },
  onLoad() {
    requestClient = new ZYRequestClient();
  },
  onShow(){
    var _this = this;
    _this.setData({
      alarmRecordList:[]
    });
    requestClient.checkFunctionPermission(1006,'您没有权限查看报警记录，请联系企业创建者！',function(){
      _this.loadAlarmRecordList();
    },function(){
      wx.navigateBack({
        delta: 1,
      })
    });
  },
  // 加载报警记录
  loadAlarmRecordList(){
    var _this = this;
    var defaultCompany = wx.getStorageSync('defaultCompany');
    if(defaultCompany == ''){
      defaultCompany = { id:0 };
    }
    requestClient.getCompanyAlarmRecordList(defaultCompany.id,function(res){
      if(res.data.data){
        _this.setData({
          alarmRecordList:res.data.data
        });
      } else {
        _this.setData({
          alarmRecordList:[]
        });
      }
    });
  }
})
